﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>{$pagetitle} - {$setting.app_title}</title>
<link rel="shortcut icon" type="image/x-icon" href="{$APP_URL}/images/favicon.ico">
<link href="{$APP_URL}/css/style.css" rel="stylesheet" type="text/css" />
<link href="{$APP_URL}/css/cometchat.css" rel="stylesheet" type="text/css" />
<link href="{$APP_URL}/js/highlight/styles/github.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="{$APP_URL}/js/formcheck/theme/classic/formcheck.css" type="text/css" media="screen" />
<script type="text/javascript">var APP = new Array();APP.URL = '{$APP_URL}';APP.TOKEN = '{$user.session_id}';APP.NEWS = {$news_json};APP.USERS_ONLINE = {$json_users_online}</script>
<script type="text/javascript" src="{$APP_URL}/combine.php?type=javascript&files=clientcide.2.2.0.compressed.js,ncode_imageresizer.js,script.js,ztips.js"></script>
<script type="text/javascript" src="{$APP_URL}/combine.php?type=javascript&files=jquery-1.3.2.min.js,cometchat.js"></script>
<script type="text/javascript" src="{$APP_URL}/js/formcheck/lang/en.js"></script>
<script type="text/javascript" src="{$APP_URL}/js/formcheck/formcheck.js"></script>
<script type="text/javascript" src="{$APP_URL}/js/highlight/highlight.pack.js"></script>
</head>
{if !empty($theme)}
<style type="text/css">
/* load user style */
body{literal}
{{/literal}
{if !empty($theme.fontcolor)}
	color: {$theme.fontcolor};
{/if}
{if !empty($theme.bgcolor)}
	background-color: {$theme.bgcolor};
{/if}
{if !empty($theme.bgimage)}
	background-image: url({$APP_URL}/images/background/{$theme.bgimage.full});
{/if}
{literal}}{/literal}
{if !empty($theme.linkcolor)}
a, a:link, a:visited{literal}
{{/literal}
	color: {$theme.linkcolor};
{literal}}
{/literal}{/if}
</style>
{/if}
<body>
<div id="topnav" class="clearfix"> 
	<div class="limit clearfix"> 
		<ul>
			<li><a href="{$APP_URL}"{if $pageid == 'home'} class="current"{/if}>หน้าแรก</a></li>
		{if ($user.is_guest)}
			<li><a href="{$APP_URL}/signup"{if $pageid == 'signup'} class="current"{/if}>สมัครสมาชิก</a></li>
			<li><a href="{$APP_URL}/signin"{if $pageid == 'signin'} class="current"{/if}>เข้าสู่ระบบ</a></li>
		{else}
			<li><a href="{$APP_URL}/search"{if $pageid == 'search'} class="current"{/if}>ค้นหา</a></li>
			<li><a href="{$APP_URL}/newtopic"{if $pageid == 'newtopic'} class="current"{/if}>ตั้งกระทู้</a></li>
			<li><a href="{$APP_URL}/profile"{if $pageid == 'profile'} class="current"{/if}>การตั้งค่า</a></li>
		{if $user.is_admin}
			<li><a href="{$APP_URL}/admin"{if $pageid == 'admin'} class="current"{/if}>จัดการระบบ</a></li>
		{/if}
			<li><a href="{$APP_URL}/signout/{$user.session_id}">ออกจากระบบ</a></li>
		{/if}
		</ul>
	</div> 
</div>
<!-- end #topnav -->
<div id="header">
{if !$user.is_guest}
	<div id="user_info">
		<div class="content">
			<div class="avatar"><img src="{$APP_URL}/avatar/{$user.avatar}" /></div>
			<div class="meta">
				<h2>สวัสดี <a href="{$APP_URL}/profile" title="ยินดีต้อนรับ {$user.realname}">{$user.realname}</a></h2>
				<p>คุณมี <span id="gift-count">{$user.gift}</span> กิ้ฟท์</p>
				<p>ขณะนี้ {$nowTime}</p>
			</div>
			<div style="clear: both;"></div>
		</div>	
	</div>
{else}
	<div id="user_info">
		<div class="content">
			<div class="avatar"><img src="{$APP_URL}/avatar/no_avatar.gif" /></div>
			<div class="meta">
				<h2>สวัสดี ผู้เยี่ยมชม</h2>
				<p><a href="{$APP_URL}/signup">สมัครสมาชิก</a> | <a href="{$APP_URL}/signin">เข้าสู่ระบบ</a></p>
				<p>ขณะนี้ {$nowTime}</p>
			</div>
			<div style="clear: both;"></div>
		</div>	
	</div>
{/if}
	<div id="logo">
		<a href="{$APP_URL}"><img src="{$APP_URL}/images/iforum-logo.png" /></a>
	</div>
</div>
<div style="clear: both;"></div>
<!-- end #header -->
{literal}
<script type="text/javascript">
window.addEvent('domready', function() {
	hljs.initHighlightingOnLoad();
	var showDuration = {/literal}{$setting.news_fader_duration} * 1000{literal};
	var currentIndex = 0;
	var fxmq = new Fx.Marquee($('news-fader'), {
		duration: 500,
		showEffect: {
			top: [20, 0],
			left: [0, 0],
			opacity: [0, 1]
		},
		hideEffect: {
			top: [0, -20],
			opacity: [1, 0]
		},
		revertEffect: {
			top: [-20, 0],
			left: [0, 0]
		}
	});
	if(APP.NEWS.length > 0){
		showNews();
	}	
	function showNews(){
		fxmq.announce({
			message: APP.NEWS[currentIndex = currentIndex < APP.NEWS.length - 1 ? currentIndex + 1 : 0].news_text,
			delay: showDuration,
			revert: false
		}).chain(showNews);
	}
	var popularSlide = new Fx.Slide('populartopics', {
		link: 'cancel',
		transition: Fx.Transitions.Quint.easeOut
	});
	var recentSlide = new Fx.Slide('recentopics', {
		link: 'cancel',
		transition: Fx.Transitions.Quint.easeOut
	});
	$$('#popularwidget h2').addEvent('click', function(e){
		e = new Event(e);
		popularSlide.toggle();
		if(popularSlide.open)
			this.set('class', 'expanded');
		else
			this.set('class', '');
		e.stop();
	});
	$$('#recentwidget h2').addEvent('click', function(e){
		e = new Event(e);
		recentSlide.toggle();
		if(recentSlide.open)
			this.set('class', 'expanded');
		else
			this.set('class', '');
		e.stop();
	});
	if(APP.USERS_ONLINE.length > 0){
		APP.USERS_ONLINE.each(function(item, index){
			$$('.bottomwidget').adopt(
				new Element('a', {
					'href': APP.URL + '/user/' + item.uid,
					'title': 'ดูโปรไฟล์ของ ' + item.realname,
					'text': item.realname
				})
			);
			if((APP.USERS_ONLINE.length -1) != index){
				$$('.bottomwidget').adopt(
					new Element('span', {
						'text': ', '
					})
				);
			}
		});
		$$('.bottomwidget .count_online').set('html', '(' + APP.USERS_ONLINE.length + ')');
	}
});
</script>
{/literal}
<div id="wrapper">
	<div id="page-bgtop"><div id="news-fader"></div></div>
	<div id="page-bgtop-sub"></div>
	<div id="page">	